package cjgl.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class MainServlet
 */
@WebServlet("/mian")
public class MainServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String pageStr = request.getParameter("page");
		Integer page= Integer.parseInt(pageStr);
		if(page==1) {
			page1(request,response);
		}else if(page==2) {
			page2(request,response);
		}else if(page==3) {
			page3(request,response);
		}else if(page==4) {
			page4(request,response);
		}
	}


	private void page4(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("page",4);
		String bjIdStr = request.getParameter("bjId");
		Integer bjId=Integer.parseInt(bjIdStr);
		if(bjId!=null) {
			request.setAttribute("bjId",bjId);
		}
			request.getRequestDispatcher("jsp/main/main4.jsp").forward(request, response);
	}


	private void page3(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("page",3);
		request.getRequestDispatcher("jsp/main/main4.jsp").forward(request, response);
	}


	private void page2(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("page",2);
		request.getRequestDispatcher("jsp/main/main4.jsp").forward(request, response);
	}


	private void page1(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("page",1);
		request.getRequestDispatcher("jsp/main/main4.jsp").forward(request, response);
		
	}


	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
